/*
 * Copyright (C) 2009 Internal Innovation Technology(IIT)
 * 
 */
package com.iitbd.hxcalc;

/**
 * This class is used for Unit Conversion
 *
 * @author Prasun Kanti Howlader <prasun@iitbd.com>
 */
public class UnitConversion {

    public Double convertSIUnit(String str, int index) {
        Double SI = Double.valueOf(str);
        switch (index) {
            case 0:
                SI = SI * 1.00000000E+00;
                break;
            case 1:
                SI = SI + 273.15;
                break;
            case 2:
                SI = (5 * (SI + 459.67)) / 9;
                break;

        }
        return SI;
    }

    public Double convertUnit(Double valueSI, int index) {
        Double tempValue = 0.0;
        switch (index) {
            case 0:
                tempValue = valueSI;
                break;
            case 1:
                tempValue = valueSI - 273.15;
                break;
            case 2:
                tempValue = valueSI * 9 / 5 - 459.67;
                break;

        }
        return tempValue;
    }
}
